//
//  WXPTotalLoanInfoCell.m
//  MexicoLoan
//
//  Created by wxp on 2025/3/17.
//

#import "WXPTotalLoanInfoCell.h"

@implementation WXPTotalLoanInfoCell

#pragma mark - lazy
- (UIView *)viewBack{
    if (_viewBack == nil) {
        _viewBack = [UIView new];
        _viewBack.backgroundColor = COLOR_WHITE;
        _viewBack.widthHeight = XY(SCREEN_WIDTH-LEFT_MARDIN*2, 0);
        _viewBack.userInteractionEnabled = true;
    }
    return _viewBack;
}
- (UILabel *)labelTitle{
    if (_labelTitle == nil) {
        _labelTitle = [UILabel new];
        _labelTitle.textColor = COLOR_CONTENT;
        _labelTitle.fontNum = 12;
    }
    return _labelTitle;
}
- (UILabel *)labelContent{
    if (_labelContent == nil) {
        _labelContent = [UILabel new];
        _labelContent.textColor = COLOR_BLACK;
        _labelContent.fontNum = 12;
    }
    return _labelContent;
}


#pragma mark - 初始化
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor clearColor];
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setUpView];
    }
    return self;
}

- (void)setUpView{
    [self.contentView addSubview:self.viewBack];
    [self.viewBack addSubview:self.labelTitle];
    [self.viewBack addSubview:self.labelContent];
    [self resetCellWithModel:nil];
}

#pragma mark - 刷新cell
- (void)resetCellWithModel:(ModelPairs *)model{
    [self.labelTitle fitTitle:readStr(model.key) variable:0];
    self.labelTitle.leftTop = XY(LEFT_MARDIN, 32);
    [self.labelContent fitTitle:readStr(model.value) variable:0];
    self.labelContent.rightCenterY = XY(self.viewBack.width-self.labelTitle.left, self.labelTitle.centerY);
    self.viewBack.height = self.labelTitle.bottom+1;
    self.viewBack.centerXTop = XY(SCREEN_WIDTH/2, 0);
    self.height = self.viewBack.bottom-1;
}

@end
